package com.chenyue.cm.base.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

public class BaseController {

    protected Integer rows = 15;

    private Logger logger = LoggerFactory.getLogger(BaseController.class);

    public ModelAndView success(HttpServletRequest request, HttpSession session, String msg, String url) {
        ModelAndView mv = new ModelAndView();
        mv.addObject("type", "success");
		mv.addObject("msg", msg);
		mv.addObject("redirect", url);
		// mv.addObject("serverurl",String.valueOf(configs.get("serverurl")));
		mv.setViewName("result");
		return mv;
	}

	@RequestMapping("/error")
	public ModelAndView error(HttpServletRequest request, HttpSession session, String msg)
			throws UnsupportedEncodingException {
		ModelAndView mv = new ModelAndView();
		mv.addObject("type", "error");
		mv.addObject("msg", URLDecoder.decode(msg, "UTF-8"));
		mv.setViewName("result");
		return mv;
	}


}
